// require('babel-core/register');

const Koa = require ('koa');
// const Router = require('koa-router');
const serve = require('koa-static');
const bodyParser = require('koa-bodyparser');
const logger = require('koa-logger');

var cors = require('koa-cors');
// const logUtils = require('./server/middlewares/log-utils');
const views = require('koa-views');
const path = require('path');

const router = require('./server/service/index');
const app = new Koa();

app.use(logger());

// app.use(logUtils());

app.use(serve(__dirname + '/static'));
// 加载模板引擎
app.use(views(path.join(__dirname, '/static'), {
  extension: 'ejs'
}));

app.use(bodyParser());

app.use(cors());
app.use(router.routes()).use(router.allowedMethods());

app.listen(5000, () => console.log('server started， port 5000'));
app.listen(5003, () => console.log('server started， port 5003'));
